window.onload = async function() {
  let majorInfo = {
    list: []
  };
  let res0 = new Promise(function(resolve, reject) {
    axios.post('api/getAllmajor').then(res => {
      res = res.data;
      if (res.error_code == 0) {
        resolve(res.data)
      }
      reject(res)
    })
  })
  await res0.then(res => {
    majorInfo.list = res;
  })
  for (let i of majorInfo.list) {
    // console.log(i)
    let elem =
      `
        <li class="media  d-block d-sm-flex"  style="margin-top: 20px" >
          <img src="${i.dir_coverUrl}" class="p-2 d-block col-12 col-sm-3 shadow-sm " alt="..." width="200">
          <div class="media-body p-2 d-block ">
            <h5 class="mt-0 mb-1 ">${i.dir_name}</h5>
            <h6>${i.dir_tchName}</h6>
            ${i.dir_Info}
            <hr>

            <button type="button" class=" openVido btn btn-primary" data-toggle="modal" data-target="#videoStaticModal"  >方向宣讲</button>
          </div>
        </li>
        `
    $('.list-unstyled').append(elem)



  }
    $('.openVido').click(function(){
        console.log('---------')
        let index=$('.openVido').index(this)
        console.log(majorInfo.list[index])
        let src= majorInfo.list[index].dir_videoUrl
        playVideo(src)
    })


  video = {}

  document.getElementById('video').style.height = window.innerHeight * 0.7 + 'px'

  function playVideo(src) {
    document.getElementById('video').src = src
  }

  $('#videoStaticModal').on('hidePrevented.bs.modal', function(e) {
    document.getElementById('video').src = ''
    // console.log(123123)
  })

  $('#videoStaticModal').on('hide.bs.modal', function() {
    document.getElementById('video').src = ''
  })

}
function logOut(){
    delete localStorage.stu_token;
    window.location.href='/'
}
